#ifndef HIFASTLOG_H__
#define HIFASTLOG_H__

#include <string.h>
#include <stdio.h>
#include <string>
#include "hilog.h"

#define LOG_MAX_SIZE 4096
#define LOG_TAIL '\n'
#define LOG_TAIL_SIZE 1


class HiFastLog: public HiLogInterface
{
protected:
    int _level;
private:
    char* log_data;
    int fd;
    bool log_to_file_tank;
    std::string filename;
public:
    HiFastLog();
    virtual ~HiFastLog();
public:
    virtual int initialize();
    virtual void log_set(const char *log_filename);
    virtual void verbose(const char* tag, int context_id, const char* fmt, ...);
    virtual void info(const char* tag, int context_id, const char* fmt, ...);
    virtual void trace(const char* tag, int context_id, const char* fmt, ...);
    virtual void warn(const char* tag, int context_id, const char* fmt, ...);
    virtual void error(const char* tag, int context_id, const char* fmt, ...);
private:
    virtual bool generate_header(bool error, const char* tag, int context_id,
                                 const char* level_name, int* header_size);
    virtual void write_log(int& fd, char* str_log, int size, int level);
    virtual void write_log_file(char *str_log, int size);
};

#endif // HIFASTLOG_H
